package vip.liux.backend.adapter.web;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import vip.liux.application.dots.PagedResultDto;
import vip.liux.backend.application.service.coupon.QueryUserCouponDto;
import vip.liux.backend.application.service.coupon.UserCouponDto;
import vip.liux.backend.application.service.coupon.UserCouponService;

@RestController
@RequestMapping("/api/user-coupon")
public class UserCouponController {

    private final UserCouponService userCouponService;

    public UserCouponController(UserCouponService userCouponService) {
        this.userCouponService = userCouponService;
    }

    /**
     * 优惠券详情
     *
     * @param id   优惠券id
     * @param code 优惠券编号
     * @return 用户优惠券数据传输对象
     */
    @GetMapping("/detail")
    public UserCouponDto detail(@RequestParam Long id, @RequestParam String code) {
        return userCouponService.detail(id, code);
    }

    @GetMapping("/received")
    public PagedResultDto<UserCouponDto> receivedList(QueryUserCouponDto input) {
        return userCouponService.receivedList(input);
    }
}